package com.situ.mymall.controller;

import com.situ.mymall.pojo.entity.OrderItem;
import com.situ.mymall.pojo.query.OrderItemQuery;
import com.situ.mymall.service.IOrderItemService;
import com.situ.mymall.util.PageResult;
import com.situ.mymall.util.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/orderItem")
public class OrderItemController {

    @Autowired
    private IOrderItemService orderItemService;


    //后台分页展示
    //order详情：由order提供的orderNo，来查询orderItem中的数据
    @RequestMapping("/list")
    public PageResult list(OrderItemQuery orderItemQuery){
        //System.out.println("---测试orderNo----: " + orderNo);
        //orderItemQuery.setOrderNo(orderNo);

        return orderItemService.list(orderItemQuery);

    }


    @RequestMapping("/selectById")
    public Result selectById(Integer id){
        OrderItem orderItem = orderItemService.selectById(id);
        return Result.ok(orderItem);
    }

    @RequestMapping("/add")
    public Result add(OrderItem orderItem){
        orderItemService.add(orderItem);
        return Result.ok("添加成功");
    }

    @RequestMapping("/deleteById")
    public Result deleteById(Integer id){
        orderItemService.deleteById(id);
        return Result.ok("删除成功");
    }

    @RequestMapping("/deleteAll")
    public Result deleteAll(Integer[] ids){
        orderItemService.deleteAll(ids);
        return Result.ok("删除成功");
    }

    //OrderItemMapper.xml未写
    @RequestMapping("/update")
    public Result update(OrderItem orderItem){
        orderItemService.update(orderItem);
        return Result.ok("更新成功");
    }


}
